<?php
    #-------------------------------------------------------------#
	# This file is part of the Kumomado - Virtual Window Platform #
	# for PHP. (c) 2009 Tsai, Min Che <tirme0812@gmail.com>       #
	# Please visit http://www.kumomado.org/ for more information. #
	#                                                             #
	# This software is licensed under the GNU License v3. Please  #
	# view the LICENSE file for the full text of this license.    #
    #-------------------------------------------------------------#

	Kumomado::load('Application.View.KumomadoApplicationView');
	Kumomado::load('Kui.KumomadoUIClient');
	/**
	 * @package applications
	 * @subpackage member
	 * @author Tsai, Min Che
	 */
	class MemberGroupView extends KumomadoApplicationView {
		public function main() {
			$lang = Kumomado::lang('main');
			$frame = new KumomadoFrame();
			$window = new KumomadoWindow('MemberGroupMain');
			$window->setTitle($lang->MemberGroupWindowTitle);
			$window->setContent($this->getLayout('main.xsl'), array('Language' => $lang->source()));
			$btn_add_group = new KumomadoButton('add_group', 'Add Group', OPEN_WINDOW);
			$btn_add_group->setParams(array(
				'app' => 'member',
				'sub_app' => 'group',
				'method' => 'form',
				'notice' => array('status' => 'add')
			));
			$btn_edit_group = new KumomadoButton('edit_group', 'Edit Group');
			$window->add($btn_add_group);
			$window->add($btn_edit_group);
			$frame->add($window);
			$this->response($frame->render());
			$this->output('json');
		}
		public function form($action) {
			$frame = new KumomadoFrame();
			$window = new KumomadoWindow('MemberGroupForm');
			$window->setSize(20, 50);
			$window->setTitle('Group Form');
			$window->setContent($this->getLayout('form.xsl'));
			$form = new KumomadoForm('group_form', KumomadoApplication::getMethodURL('insertGroup'));
			$hid_id = new KumomadoHidden('group_id', 1);
			$txt_name = new KumomadoTextBox('group_name');
			$sel_group = new KumomadoSelect('group_parent');
			$txa_desc = new KumomadoTextArea('group_desc');
			$groups = $this->groups;
			foreach ($groups as $group) {
				$sel_group->addOption($group['group_id'], $group['group_name']);
			}
			$form->add($hid_id);
			$form->add($txt_name, 'Group Name:');
			$form->add($sel_group, 'Parent Group:');
			$form->add($txa_desc, 'Group Description:');
			$window->add($form);
			$frame->add($window);
			$this->response($frame->render());
			$this->output('json');
		}
	}
?>